
import {baseUrl,topList,listDetail,songDetail,simiDetail,commentDetail,lyricDetail,songUrlDetail,searchHotDetail,songKeywordsDetail,songSuggestDetail,} from './url.js'

//各个榜单（首页使用）
const topListData = `${baseUrl}${topList}`  

//具体榜单详情（二级页面使用）
const detailData = `${baseUrl}${listDetail}` 

 //三级页面使用
const songData = `${baseUrl}${songDetail}`
const simiData = `${baseUrl}${simiDetail}`
const commentData = `${baseUrl}${commentDetail}`
const lyricData = `${baseUrl}${lyricDetail}`
const songUrlData = `${baseUrl}${songUrlDetail}`

//搜索页面接口
const searchHotData = `${baseUrl}${searchHotDetail}`
const songKeywordsData = `${baseUrl}${songKeywordsDetail}`
const songSuggestData = `${baseUrl}${songSuggestDetail}`

export function topData(){
	return new Promise(function (resolve, reject){
		uni.request({
			url: topListData,
			method: 'GET',
			success: res => {
				let result = res.data.list
				result.length = 3				
				resolve(result)
			},
			fail: () => {
				reject("请求失败")
			},
			complete: () => {}
		});
	})
	
}

export function listDetailData(ids){
	return uni.request({
		url: detailData,
		method: 'GET',
		data: {
			id:ids,
			}
	});
}

	
export function songDetails(ids){
	return uni.request({
		url: songData,
		method: 'GET',
		data: {
			ids:ids,
			}
	});
}


	
export function simiSong(id){
	return uni.request({
		url: simiData,
		method: 'GET',
		data: {
			id:id,
			}
	});
}

export function commentMusic(id){
	return uni.request({
		url: commentData,
		method: 'GET',
		data: {
			id:id,
			limit:10,
			}
	});
}


export function lyric(id){
	return uni.request({
		url: lyricData,
		method: 'GET',
		data: {
			id:id,
			}
	});
}

export function songUrl(id){
	return uni.request({
		url: songUrlData,
		method: 'GET',
		data: {
			id:id,
			}
	});
}


export function searchHot(){
	return uni.request({
		url: searchHotData,
		method: 'GET',
	});
}

export function songKeywords(keywords){
	return uni.request({
		url: songKeywordsData,
		method: 'GET',
		data: {
			keywords:keywords,
			}
	});
}


export function songSuggest(keywords){
	return uni.request({
		url: songSuggestData,
		method: 'GET',
		data: {
			keywords:keywords,
			type:"mobile"
			}
	});
}